package com.copractice.data.entity.user;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import com.copractice.data.entity.PersistentObject;

/**
 * Represents user entity.
 *
 * @author Dmitry Churbanov (dmitry.churbanov@gmail.com)
 * @version 1.0 13.03.2009
 */
@Entity
@Table(name = "USERS")
@NamedQuery(name="USERS.getUserByName", query="select u from User u where u.userName = :name")
@SuppressWarnings("serial")
public class User extends PersistentObject {
    
    /**
     * Contains users name
     */
    private String userName;

    /**
     * Contains users password
     */
    private String password;

    /**
     *Contains users first name 
     */
    private String firstName;

    /**
     * Contains users last name
     */
    private String lastName;

    /**
     * Contains users middle name
     */
    private String middleName;

    /**
     * Contains users email
     */
    private String email;

    /**
     * Contains users type
     */
    private UserType type;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Override
    public Long getId() {
        return super.getId();
    }

    /**
     * Gets user name
     *
     * @return user name
     */
    @Column(name = "USERNAME", nullable = false)
    public String getUserName() {
        return userName;
    }

    /**
     * Sets user name
     *
     * @param userName name of a user
     */
    public void setUserName(String userName) {
        this.userName = userName;
    }

    /**
     * Gets password
     *
     * @return users password
     */
    @Column(name = "PASSWORD", nullable = false)
    public String getPassword() {
        return password;
    }

    /**
     * Sets password
     *
     * @param password users password
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * Gets users first name
     *
     * @return users first name
     */
    @Column(name = "FIRSTNAME", nullable = false)
    public String getFirstName() {
        return firstName;
    }

    /**
     * Sets users first name
     *
     * @param firstName users first name
     */
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    /**
     * Gets users last name
     *
     * @return users last name
     */
    @Column(name = "LASTNAME", nullable = false)
    public String getLastName() {
        return lastName;
    }

    /**
     * Sets users last name
     * 
     * @param lastName users last name
     */
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    /**
     * Gets users middle name
     *
     * @return users middle name
     */
    @Column(name = "MIDDLENAME", nullable = true)
    public String getMiddleName() {
        return middleName;
    }

    /**
     * Sets users middle name
     *
     * @param middleName users middle name
     */
    public void setMiddleName(String middleName) {
        this.middleName = middleName;
    }

    /**
     * Gets users email
     *
     * @return users email
     */
    @Column(name = "EMAIL", nullable = false)
    public String getEmail() {
        return email;
    }

    /**
     * Sets users email
     *
     * @param email users email
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * Gets users type
     *
     * @return users type
     */
    @Column(name = "TYPE", nullable = false)
    public UserType getType() {
        return type;
    }

    /**
     * Sets users type
     *
     * @param type users type
     */
    public void setType(UserType type) {
        this.type = type;
    }    

}
